<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>日志审计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <blockquote class="layui-elem-quote layui-text">
            说明:<br>
        </blockquote>

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">帐号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="login_user" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline" id="timeSelect">
                            <label class="layui-form-label">时间范围</label>
                            <div class="layui-input-inline" style="width:200px">
                              <input type="txt" id="starttime" name="starttime" value="" class="layui-input textboxtime" placeholder="开始时间" />
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline" style="width:200px">
                              <input type="txt" id="endtime" name="endtime" value="" class="layui-input textboxtime" placeholder="结束时间" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <script type="text/html" id="toolbarDemo">

        </script>

        <table class="layui-table" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
        </script>

    </div>
</div>
<script type="text/html" id="statusTpl">
  {{# if (d.status == 'success') { }}
     <span style="color:#218868">成功</span>
	{{# } else { }}
    <span style="color:#FF5722">失败</span>
{{# } }}
</script>	
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','laydate'], function () {
        var $ = layui.jquery,
            form = layui.form,
            laydate = layui.laydate,
            table = layui.table;

        lay('.textboxtime').each(function(){
          laydate.render({
            elem: this,
        	  type: 'datetime',
            format: 'yyyy-MM-dd HH:mm:ss'
          });
        });

        table.render({
            elem: '#currentTableId',
            url: '/rbac/audit/List',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                //{type: "checkbox", width: 50},
                {field: 'id', width:70, title: 'ID', sort: true},
                {field: 'login_user', width:150,title: '帐号'},
                {field: 'user_ip', width:250,title: '用户IP', sort: true},
                {field: 'status', title: '状态',templet: '#statusTpl', width: 100, sort: true},
                {field: 'action', width:150,title: '动作',sort: true},
                {field: 'message', title: '消息'},
                {field: 'createtime', width:180,title: '登录时间'}              
            ]],
            limits: [25, 50, 100],
            limit: 15,
            page: true
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            data.field.login_user = data.field.login_user.replace(/\s+/g,""); //替换空格
            var result = JSON.stringify(data.field);
            table.reload('currentTableId', {
                //page: {
                //    curr: 1,
                //    limit:50
                //},
                method:'POST',
                url: '/rbac/audit/List',
                contentType: 'application/json',
                where: data.field,
                done: function(res, curr, count){
                }
            }, 'data');

            return false;
        });
    });
</script>

</body>
</html>